<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
$(document).ready(function() {
	$("#return").click(function() {
		location.href = "/service/notice";
	});
	
	$("#save").click(function() {
		if($("#typeCd").val() == '') {
			alert("공지분류를 선택해 주세요.");
			return false;
		}
		
		if($("#title").val() == '') {
			alert("공지제목을 입력해 주세요.");
			return false;
		}
		
		if($("#contents").val() == '') {
			alert("공지내용을 입력해 주세요.");
			return false;
		}
		
		if(confirm("등록하시겠습니까?")) {
			document.forms[0].submit();
		}
		
		return false;
	});
});
</script>
</head>
<body>
<div class="content_top">
	<p class="path">
		<strong>공지사항</strong>
	</p>
</div>
<h4>분류별 공지사항이 보여지며, 등록, 수정 가능합니다.</h4>

<form:form modelAttribute="noticeModel" action="/service/notice/write" method="post">
<input type="hidden" id="noticeNo" name="noticeNo" value="${noticeModel.noticeNo}">
<div class="tbl_type3">
	<table cellspacing="0" border="1">
	<col width="120">
	<col>
	<col width="120">
	<col>
	<tr>
		<th>공지분류</th>
		<td>
			<select id="typeCd" name="typeCd" style="width: 80px;">
				<option value="">선택</option>
				<c:forEach items="${typeCdList}" var="item">
				<option <c:if test="${noticeModel.typeCd eq item.commonCode}"> selected="selected"</c:if> value="${item.commonCode}">${item.commonName}</option>
				</c:forEach>
			</select>
		</td>
		<th>노출여부</th>
		<td>
			<input type="radio" class="rdo" name="useYn" value="Y" <c:if test="${noticeModel.useYn eq 'Y'}"> checked="checked"</c:if> checked="checked"><span>노출</span></input>  
			<input type="radio" class="rdo" name="useYn" value="N" <c:if test="${noticeModel.useYn eq 'N'}"> checked="checked"</c:if>><span>숨김</span></input>
		</td>
	</tr>
	<tr>
		<th>제목</th>
		<td colspan="3">
			<input id="title" name="title" type="text" class="input_txt" style="width: 100%" value="${noticeModel.title}">
		</td>
	</tr>
	<tr>
		<th>내용</th>
		<td colspan="3">
			<textarea id="contents" name="contents" class="input_txt" style="width: 100%; height: 300px;" rows="50" cols="10">${noticeModel.contents}</textarea>
		</td>
	</tr>
	</table>
</div>
<br>

<div class="div_right">
	<a href="#" class="btn_sml" id="return"><span>목록보기</span></a>
	<a href="#" class="btn_sml" id="save"><span>등록하기</span></a>
</div>
</form:form>
</body>
</html>